/**
 * HttpSessionListner interface 負責通知 session 的生成事件和消滅事件
 */

package basic;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.e885.log.E885Logger;

/**
 * url:http://127.0.0.1:8080/JSPSessionListener/basic<br>
 * <br>
 * 當我們取得 session 使用 request.getSesscion() 時, session 會被載入, 同時會通知正在 listner 的物件(MySessionListener.sessionCreated())。<br>
 * 所以在這裏我們就可以測試 HttpSessionListener.sessionCreated() 何時被呼叫。<br>
 * 同理，我們也測試了 HttpSessionListener.sessionDestroyed() 是當我們呼叫 session.invalidate() 被呼叫。
 * 
 * @author Eric.Kao(gau168.gau@msa.hinet.net)
 * @version 1.0
 * @company E885 Group
 * @copyright Copyright (c) 2001-2008
 */

public class BasicServlet extends HttpServlet
{
	private static final long serialVersionUID = 1010247187762702135L;

	protected void service( HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException
	{
		E885Logger.testLog.info( "=========== start request.getSession() ===========" );
		HttpSession session = request.getSession( true );
		E885Logger.testLog.info( "============== end request.getSession() ===================" );

		E885Logger.testLog.debug( "==================== start session destroy ===================" );
		session.invalidate();
		E885Logger.testLog.debug( "==================== end session destroy ===================" );
	}

}
